Skip to content

Conversation

@Kevinlzh9802
Copy link
Contributor

No description provided.

Kevinlzh9802 and others added 24 commits July 5, 2024 14:25
write rx with UUID

add badge_bleak

add badge_bleak

add badge_bleak

add badge_bleak

add badge_bleak

add badge_bleak

rewrite utilities using bleak

add request handler decorators

add request handler decorators

add request handler decorators

add request handler decorators

add request handler decorators

rewrite utilities using bleak

add request handler decorators
# Conflicts:
#	BadgeFramework/badge.py
#	BadgeFramework/bleak_test.py
@@ -0,0 +1,363 @@
import tkinter as tk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Era-Dorta remove this file and make badge_gui use from badge import OpenBadge

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review this file and remove the original gui file

print(" mic gain: FAIL ")
else:
print(" mic mode: FAIL ")
print(" mic mode: FAIL ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be updated to bleak

Copy link
Contributor

@Era-Dorta Era-Dorta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing the GUI file

import pandas as pd
from badge import OpenBadge
from datetime import datetime
# import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import

Suggested change
# import numpy as np

import sys
import time
import ntplib
# from functools import partial
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import

Suggested change
# from functools import partial

# import numpy as np
import sys
import time
import ntplib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove ntplib

Suggested change
import ntplib

Comment on lines 339 to 359
# def get_ntp_time(ntp_server='pool.ntp.org'):
# # Create an NTP client
# client = ntplib.NTPClient()
#
# try:
# # Query the NTP server
# response = client.request(ntp_server)
#
# # Convert the response to datetime
# ntp_time = datetime.fromtimestamp(response.tx_time, tz=timezone.utc)
# print("NTP time:", ntp_time.strftime('%Y-%m-%d %H:%M:%S %Z'))
# return ntp_time
#
# except Exception as e:
# print("Could not connect to NTP server:", e)
# return None


# Use a local NTP server (replace with your server IP if needed)
# ntp_server_ip = '192.168.1.100' # Example IP for a local NTP server
# ntp_time = get_ntp_time(ntp_server=ntp_server_ip)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code

Suggested change
# def get_ntp_time(ntp_server='pool.ntp.org'):
# # Create an NTP client
# client = ntplib.NTPClient()
#
# try:
# # Query the NTP server
# response = client.request(ntp_server)
#
# # Convert the response to datetime
# ntp_time = datetime.fromtimestamp(response.tx_time, tz=timezone.utc)
# print("NTP time:", ntp_time.strftime('%Y-%m-%d %H:%M:%S %Z'))
# return ntp_time
#
# except Exception as e:
# print("Could not connect to NTP server:", e)
# return None
# Use a local NTP server (replace with your server IP if needed)
# ntp_server_ip = '192.168.1.100' # Example IP for a local NTP server
# ntp_time = get_ntp_time(ntp_server=ntp_server_ip)

return_message = await sensor_operation(t=datetime.now().timestamp())
else:
return_message = await sensor_operation()
# print(return_message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# print(return_message)


self.title("Badge Status Monitor")
self.badges = pd.read_csv('mappings2.csv')
# self.badges = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all commented out code

self.scrollbar.grid(row=0, column=0, sticky="ns")
self.canvas.grid(row=0, column=1, sticky="nsew")

# Bind mouse scroll to canvas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all comments that do not add anything to the code, as this one, which says the say as the function name

self.timestamp_labels[badge] = (timestamp_label, elapsed_time_label)
self.sensor_lights[badge] = sensor_light_canvases

def bind_mouse_scroll(self, widget):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add type hints to all the functions?


def get_badge_address(self, badge_id: int) -> str:
badge = self.badges[self.badges['Participant Id'] == badge_id]
address = badge['Mac Address'].to_numpy()[0] # There should be a more elegant way to do this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about?

Suggested change
address = badge['Mac Address'].to_numpy()[0] # There should be a more elegant way to do this
address = badge['Mac Address'].values[0]

Copy link
Contributor

@Era-Dorta Era-Dorta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional review

Comment on lines +14 to +26
SENSOR_ALL = 0
SENSOR_MICROPHONE = 1
SENSOR_IMU = 2
SENSOR_SCAN = 3
SENSOR_CHECK_STATUS = 100
SENSOR_TIMEOUT = 15

SENSOR_START = True
SENSOR_STOP = False
CHECK_SYNC = True
CHECK_NO_SYNC = False

BADGES_ALL = -1000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain all of these constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just like the response_tags in badge_protocol to increase readability when passing the parameters.

sync_button.grid(row=0, column=10, padx=5, pady=5)

# Create rows for each badge
badges_list = list(range(1, len(self.badges) + 5))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes no sense, why make the list longer by 5?

Response_free_sdc_space_response_tag = 5
Response_sdc_errase_all_response_tag = 32
Response_get_imu_data_response_tag = 34

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what happened with this file but I think all the changes should be removed

Comment on lines -28 to +30
nrf_delay_ms(100);
nrf_delay_ms(1000);
nrf_gpio_pin_write(LED, LED_OFF); //turn off LED
nrf_delay_ms(100);
nrf_delay_ms(1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to also revert this changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants